<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>个人信息管理</title>
  </head>
  <body>
    <div id="form_base_info">
    </div>
    <script>
        Ext.onReady(function(){
            /*
             * Ext.ux.ItemSelector Example Code
             */
            tabs.getActiveTab().setTitle('个人信息管理');
            var customerName = new Ext.form.TextField({
                fieldLabel: '姓名',
                allowBlank: false,
                name: 'name',
                anchor: '90%'
            });

            var phone = new Ext.form.TextField({
                fieldLabel: '个人电话',
                allowBlank: false,
                name: 'phone',
                anchor: '90%'
            });
                
            var email = new Ext.form.TextField({
                fieldLabel: '电子邮件',
                allowBlank: false,
                name: 'email',
                vtype: 'email',
                anchor: '90%'
            });
                
            var card = new Ext.form.TextField({
                fieldLabel: '身份证',
                allowBlank: false,
                name: 'card',
                anchor: '90%'
            });
                
            var address = new Ext.form.TextField({
                fieldLabel: '地址',
                allowBlank: false,
                name: 'address',
                anchor: '90%'
            });
                
            var formBaseInfo = new Ext.form.FormPanel({
                labelWidth: 80,
                frame: true,
                labelAlign: 'right',
                width: 550,
                url: '/web_user/setPersonBaseInfo',
                reader: new Ext.data.JsonReader({
                    root: 'root'
                }, [{
                        name: 'name'
                    }, {
                        name: 'phone'
                    }, {
                        name: 'email'
                    }, {
                        name: 'card'
                    }, {
                        name: 'address'
                    }]),
                items: [customerName, email, phone, card, address],
                buttons: [{
                        text: '确定',
                        handler: onItemClick //实际应用一般是处理fp.getForm.submit()事件   
                    }]
            });
            formBaseInfo.render("form_base_info");
            function onItemClick(item){
                if (formBaseInfo.form.isValid()) {
                    formBaseInfo.form.submit({
                        waitMsg: '正在提交......',
                        success: function(form, action){
                            Ext.MessageBox.alert("提示", "基本信息保存成功！");
                        },
                        failure: function(form, action){
                            Ext.MessageBox.alert('提交错误消息', '提交失败');
                        }
                    });
                }
                else {
                    Ext.MessageBox.alert("提示", "请按要求填写带<span class='red'>*</span>的必输值！");
                }
            }
                                
            // load form and assign value to fields
            formBaseInfo.form.load({
                url: '/web_user/getPersonBaseInfoByID',
                waitMsg: '正在载入数据...',
                success: function(form, action){
                },
                failure: function(form, action){
                    Ext.MessageBox.alert('提示信息', '信息加载失败');
                }
            });
        })
    </script>
  </body>
</html>
